<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*! base64x-1.1.5 (c) 2012-2015 Kenji Urushima | kjur.github.com/jsjws/license
<span class='line'>  2</span>  */</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="COMM">/*
<span class='line'>  4</span>  * base64x.js - Base64url and supplementary functions for Tom Wu's base64.js library
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * version: 1.1.5 (2015-Sep-13)
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * Copyright (c) 2012-2015 Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'>  9</span>  *
<span class='line'> 10</span>  * This software is licensed under the terms of the MIT License.
<span class='line'> 11</span>  * http://kjur.github.com/jsjws/license/
<span class='line'> 12</span>  *
<span class='line'> 13</span>  * The above copyright and license notice shall be 
<span class='line'> 14</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 15</span>  *
<span class='line'> 16</span>  * DEPENDS ON:
<span class='line'> 17</span>  *   - base64.js - Tom Wu's Base64 library
<span class='line'> 18</span>  */</span><span class="WHIT">
<span class='line'> 19</span> 
<span class='line'> 20</span> </span><span class="COMM">/**
<span class='line'> 21</span>  * @fileOverview
<span class='line'> 22</span>  * @name base64x-1.1.js
<span class='line'> 23</span>  * @author Kenji Urushima kenji.urushima@gmail.com
<span class='line'> 24</span>  * @version asn1 1.1.5 (2015-Sep-13)
<span class='line'> 25</span>  * @since jsrsasign 2.1
<span class='line'> 26</span>  * @license &lt;a href="http://kjur.github.io/jsrsasign/license/">MIT License&lt;/a>
<span class='line'> 27</span>  */</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="COMM">/**
<span class='line'> 30</span>  * Base64URL and supplementary functions for Tom Wu's base64.js library.&lt;br/>
<span class='line'> 31</span>  * This class is just provide information about global functions
<span class='line'> 32</span>  * defined in 'base64x.js'. The 'base64x.js' script file provides
<span class='line'> 33</span>  * global functions for converting following data each other.
<span class='line'> 34</span>  * &lt;ul>
<span class='line'> 35</span>  * &lt;li>(ASCII) String&lt;/li>
<span class='line'> 36</span>  * &lt;li>UTF8 String including CJK, Latin and other characters&lt;/li>
<span class='line'> 37</span>  * &lt;li>byte array&lt;/li>
<span class='line'> 38</span>  * &lt;li>hexadecimal encoded String&lt;/li>
<span class='line'> 39</span>  * &lt;li>Full URIComponent encoded String (such like "%69%94")&lt;/li>
<span class='line'> 40</span>  * &lt;li>Base64 encoded String&lt;/li>
<span class='line'> 41</span>  * &lt;li>Base64URL encoded String&lt;/li>
<span class='line'> 42</span>  * &lt;/ul>
<span class='line'> 43</span>  * All functions in 'base64x.js' are defined in {@link global__} and not
<span class='line'> 44</span>  * in this class.
<span class='line'> 45</span>  * 
<span class='line'> 46</span>  * @class Base64URL and supplementary functions for Tom Wu's base64.js library
<span class='line'> 47</span>  * @author Kenji Urushima
<span class='line'> 48</span>  * @version 1.1 (07 May 2012)
<span class='line'> 49</span>  * @requires base64.js
<span class='line'> 50</span>  * @see &lt;a href="http://kjur.github.com/jsjws/">'jwjws'(JWS JavaScript Library) home page http://kjur.github.com/jsjws/&lt;/a>
<span class='line'> 51</span>  * @see &lt;a href="http://kjur.github.com/jsrsasigns/">'jwrsasign'(RSA Sign JavaScript Library) home page http://kjur.github.com/jsrsasign/&lt;/a>
<span class='line'> 52</span>  */</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Base64x</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 55</span> 
<span class='line'> 56</span> </span><span class="COMM">// ==== string / byte array ================================</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="COMM">/**
<span class='line'> 58</span>  * convert a string to an array of character codes
<span class='line'> 59</span>  * @param {String} s
<span class='line'> 60</span>  * @return {Array of Numbers} 
<span class='line'> 61</span>  */</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stoBA</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">	</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 69</span> 
<span class='line'> 70</span> </span><span class="COMM">/**
<span class='line'> 71</span>  * convert an array of character codes to a string
<span class='line'> 72</span>  * @param {Array of Numbers} a array of character codes
<span class='line'> 73</span>  * @return {String} s
<span class='line'> 74</span>  */</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">BAtos</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 82</span> 
<span class='line'> 83</span> </span><span class="COMM">// ==== byte array / hex ================================</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="COMM">/**
<span class='line'> 85</span>  * convert an array of bytes(Number) to hexadecimal string.&lt;br/>
<span class='line'> 86</span>  * @param {Array of Numbers} a array of bytes
<span class='line'> 87</span>  * @return {String} hexadecimal string
<span class='line'> 88</span>  */</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">BAtohex</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hex1.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 98</span> 
<span class='line'> 99</span> </span><span class="COMM">// ==== string / hex ================================</span><span class="WHIT">
<span class='line'>100</span> </span><span class="COMM">/**
<span class='line'>101</span>  * convert a ASCII string to a hexadecimal string of ASCII codes.&lt;br/>
<span class='line'>102</span>  * NOTE: This can't be used for non ASCII characters.
<span class='line'>103</span>  * @param {s} s ASCII string
<span class='line'>104</span>  * @return {String} hexadecimal string
<span class='line'>105</span>  */</span><span class="WHIT">
<span class='line'>106</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">BAtohex</span><span class="PUNC">(</span><span class="NAME">stoBA</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>109</span> 
<span class='line'>110</span> </span><span class="COMM">// ==== string / base64 ================================</span><span class="WHIT">
<span class='line'>111</span> </span><span class="COMM">/**
<span class='line'>112</span>  * convert a ASCII string to a Base64 encoded string.&lt;br/>
<span class='line'>113</span>  * NOTE: This can't be used for non ASCII characters.
<span class='line'>114</span>  * @param {s} s ASCII string
<span class='line'>115</span>  * @return {String} Base64 encoded string
<span class='line'>116</span>  */</span><span class="WHIT">
<span class='line'>117</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>120</span> 
<span class='line'>121</span> </span><span class="COMM">// ==== string / base64url ================================</span><span class="WHIT">
<span class='line'>122</span> </span><span class="COMM">/**
<span class='line'>123</span>  * convert a ASCII string to a Base64URL encoded string.&lt;br/>
<span class='line'>124</span>  * NOTE: This can't be used for non ASCII characters.
<span class='line'>125</span>  * @param {s} s ASCII string
<span class='line'>126</span>  * @return {String} Base64URL encoded string
<span class='line'>127</span>  */</span><span class="WHIT">
<span class='line'>128</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stob64u</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>130</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>131</span> 
<span class='line'>132</span> </span><span class="COMM">/**
<span class='line'>133</span>  * convert a Base64URL encoded string to a ASCII string.&lt;br/>
<span class='line'>134</span>  * NOTE: This can't be used for Base64URL encoded non ASCII characters.
<span class='line'>135</span>  * @param {s} s Base64URL encoded string
<span class='line'>136</span>  * @return {String} ASCII string
<span class='line'>137</span>  */</span><span class="WHIT">
<span class='line'>138</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64utos</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">BAtos</span><span class="PUNC">(</span><span class="NAME">b64toBA</span><span class="PUNC">(</span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>141</span> 
<span class='line'>142</span> </span><span class="COMM">// ==== base64 / base64url ================================</span><span class="WHIT">
<span class='line'>143</span> </span><span class="COMM">/**
<span class='line'>144</span>  * convert a Base64 encoded string to a Base64URL encoded string.&lt;br/>
<span class='line'>145</span>  * Example: "ab+c3f/==" &rarr; "ab-c3f_"
<span class='line'>146</span>  * @param {String} s Base64 encoded string
<span class='line'>147</span>  * @return {String} Base64URL encoded string
<span class='line'>148</span>  */</span><span class="WHIT">
<span class='line'>149</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\=/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\//g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"_"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>155</span> 
<span class='line'>156</span> </span><span class="COMM">/**
<span class='line'>157</span>  * convert a Base64URL encoded string to a Base64 encoded string.&lt;br/>
<span class='line'>158</span>  * Example: "ab-c3f_" &rarr; "ab+c3f/=="
<span class='line'>159</span>  * @param {String} s Base64URL encoded string
<span class='line'>160</span>  * @return {String} Base64 encoded string
<span class='line'>161</span>  */</span><span class="WHIT">
<span class='line'>162</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"=="</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/-/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"+"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/_/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>169</span> 
<span class='line'>170</span> </span><span class="COMM">// ==== hex / base64url ================================</span><span class="WHIT">
<span class='line'>171</span> </span><span class="COMM">/**
<span class='line'>172</span>  * convert a hexadecimal string to a Base64URL encoded string.&lt;br/>
<span class='line'>173</span>  * @param {String} s hexadecimal string
<span class='line'>174</span>  * @return {String} Base64URL encoded string
<span class='line'>175</span>  * @description
<span class='line'>176</span>  * convert a hexadecimal string to a Base64URL encoded string.
<span class='line'>177</span>  * NOTE: If leading "0" is omitted and odd number length for
<span class='line'>178</span>  * hexadecimal leading "0" is automatically added.
<span class='line'>179</span>  */</span><span class="WHIT">
<span class='line'>180</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextob64u</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>184</span> 
<span class='line'>185</span> </span><span class="COMM">/**
<span class='line'>186</span>  * convert a Base64URL encoded string to a hexadecimal string.&lt;br/>
<span class='line'>187</span>  * @param {String} s Base64URL encoded string
<span class='line'>188</span>  * @return {String} hexadecimal string
<span class='line'>189</span>  */</span><span class="WHIT">
<span class='line'>190</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>193</span> 
<span class='line'>194</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">utf8tob64u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b64utoutf8</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> 
<span class='line'>196</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Buffer</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>197</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">  </span><span class="NAME">utf8tob64u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">  </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Buffer</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'utf8'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="STRN">'base64'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> 
<span class='line'>203</span> </span><span class="WHIT">  </span><span class="NAME">b64utoutf8</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">  </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Buffer</span><span class="PUNC">(</span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'base64'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="STRN">'utf8'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>208</span> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>209</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>210</span> </span><span class="COMM">// ==== utf8 / base64url ================================</span><span class="WHIT">
<span class='line'>211</span> </span><span class="COMM">/**
<span class='line'>212</span>  * convert a UTF-8 encoded string including CJK or Latin to a Base64URL encoded string.&lt;br/>
<span class='line'>213</span>  * @param {String} s UTF-8 encoded string
<span class='line'>214</span>  * @return {String} Base64URL encoded string
<span class='line'>215</span>  * @since 1.1
<span class='line'>216</span>  */</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">  </span><span class="NAME">utf8tob64u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">  </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextob64u</span><span class="PUNC">(</span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> 
<span class='line'>222</span> </span><span class="COMM">/**
<span class='line'>223</span>  * convert a Base64URL encoded string to a UTF-8 encoded string including CJK or Latin.&lt;br/>
<span class='line'>224</span>  * @param {String} s Base64URL encoded string
<span class='line'>225</span>  * @return {String} UTF-8 encoded string
<span class='line'>226</span>  * @since 1.1
<span class='line'>227</span>  */</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">  </span><span class="NAME">b64utoutf8</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">  </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>232</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>233</span> 
<span class='line'>234</span> </span><span class="COMM">// ==== utf8 / base64url ================================</span><span class="WHIT">
<span class='line'>235</span> </span><span class="COMM">/**
<span class='line'>236</span>  * convert a UTF-8 encoded string including CJK or Latin to a Base64 encoded string.&lt;br/>
<span class='line'>237</span>  * @param {String} s UTF-8 encoded string
<span class='line'>238</span>  * @return {String} Base64 encoded string
<span class='line'>239</span>  * @since 1.1.1
<span class='line'>240</span>  */</span><span class="WHIT">
<span class='line'>241</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">utf8tob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> 
<span class='line'>245</span> </span><span class="COMM">/**
<span class='line'>246</span>  * convert a Base64 encoded string to a UTF-8 encoded string including CJK or Latin.&lt;br/>
<span class='line'>247</span>  * @param {String} s Base64 encoded string
<span class='line'>248</span>  * @return {String} UTF-8 encoded string
<span class='line'>249</span>  * @since 1.1.1
<span class='line'>250</span>  */</span><span class="WHIT">
<span class='line'>251</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64toutf8</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>253</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>254</span> 
<span class='line'>255</span> </span><span class="COMM">// ==== utf8 / hex ================================</span><span class="WHIT">
<span class='line'>256</span> </span><span class="COMM">/**
<span class='line'>257</span>  * convert a UTF-8 encoded string including CJK or Latin to a hexadecimal encoded string.&lt;br/>
<span class='line'>258</span>  * @param {String} s UTF-8 encoded string
<span class='line'>259</span>  * @return {String} hexadecimal encoded string
<span class='line'>260</span>  * @since 1.1.1
<span class='line'>261</span>  */</span><span class="WHIT">
<span class='line'>262</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">utf8tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>265</span> 
<span class='line'>266</span> </span><span class="COMM">/**
<span class='line'>267</span>  * convert a hexadecimal encoded string to a UTF-8 encoded string including CJK or Latin.&lt;br/>
<span class='line'>268</span>  * Note that when input is improper hexadecimal string as UTF-8 string, this function returns
<span class='line'>269</span>  * 'null'.
<span class='line'>270</span>  * @param {String} s hexadecimal encoded string
<span class='line'>271</span>  * @return {String} UTF-8 encoded string or null
<span class='line'>272</span>  * @since 1.1.1
<span class='line'>273</span>  */</span><span class="WHIT">
<span class='line'>274</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextoutf8</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>277</span> 
<span class='line'>278</span> </span><span class="COMM">/**
<span class='line'>279</span>  * convert a hexadecimal encoded string to raw string including non printable characters.&lt;br/>
<span class='line'>280</span>  * @param {String} s hexadecimal encoded string
<span class='line'>281</span>  * @return {String} raw string
<span class='line'>282</span>  * @since 1.1.2
<span class='line'>283</span>  * @example
<span class='line'>284</span>  * hextorstr("610061") &rarr; "a\x00a"
<span class='line'>285</span>  */</span><span class="WHIT">
<span class='line'>286</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextorstr</span><span class="PUNC">(</span><span class="NAME">sHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">sHex.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">        </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">sHex.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>293</span> 
<span class='line'>294</span> </span><span class="COMM">/**
<span class='line'>295</span>  * convert a raw string including non printable characters to hexadecimal encoded string.&lt;br/>
<span class='line'>296</span>  * @param {String} s raw string
<span class='line'>297</span>  * @return {String} hexadecimal encoded string
<span class='line'>298</span>  * @since 1.1.2
<span class='line'>299</span>  * @example
<span class='line'>300</span>  * rstrtohex("a\x00a") &rarr; "610061"
<span class='line'>301</span>  */</span><span class="WHIT">
<span class='line'>302</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">rstrtohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">        </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>309</span> 
<span class='line'>310</span> </span><span class="COMM">// ==== hex / b64nl =======================================</span><span class="WHIT">
<span class='line'>311</span> 
<span class='line'>312</span> </span><span class="COMM">/*
<span class='line'>313</span>  * since base64x 1.1.3
<span class='line'>314</span>  */</span><span class="WHIT">
<span class='line'>315</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>318</span> 
<span class='line'>319</span> </span><span class="COMM">/*
<span class='line'>320</span>  * since base64x 1.1.3
<span class='line'>321</span>  */</span><span class="WHIT">
<span class='line'>322</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextob64nl</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>323</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b64</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hextob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b64nl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64.replace</span><span class="PUNC">(</span><span class="REGX">/(.{64})/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"$1\r\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">    </span><span class="NAME">b64nl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64nl.replace</span><span class="PUNC">(</span><span class="REGX">/\r\n$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64nl</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>327</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>328</span> 
<span class='line'>329</span> </span><span class="COMM">/*
<span class='line'>330</span>  * since base64x 1.1.3
<span class='line'>331</span>  */</span><span class="WHIT">
<span class='line'>332</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64nltohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b64</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/[^0-9A-Za-z\/+=]*/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">b64</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span> </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>337</span> 
<span class='line'>338</span> </span><span class="COMM">// ==== URIComponent / hex ================================</span><span class="WHIT">
<span class='line'>339</span> </span><span class="COMM">/**
<span class='line'>340</span>  * convert a URLComponent string such like "%67%68" to a hexadecimal string.&lt;br/>
<span class='line'>341</span>  * @param {String} s URIComponent string such like "%67%68"
<span class='line'>342</span>  * @return {String} hexadecimal string
<span class='line'>343</span>  * @since 1.1
<span class='line'>344</span>  */</span><span class="WHIT">
<span class='line'>345</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/%/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>347</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>348</span> 
<span class='line'>349</span> </span><span class="COMM">/**
<span class='line'>350</span>  * convert a hexadecimal string to a URLComponent string such like "%67%68".&lt;br/>
<span class='line'>351</span>  * @param {String} s hexadecimal string
<span class='line'>352</span>  * @return {String} URIComponent string such like "%67%68"
<span class='line'>353</span>  * @since 1.1
<span class='line'>354</span>  */</span><span class="WHIT">
<span class='line'>355</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/(..)/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"%$1"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>357</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>358</span> 
<span class='line'>359</span> </span><span class="COMM">// ==== URIComponent ================================</span><span class="WHIT">
<span class='line'>360</span> </span><span class="COMM">/**
<span class='line'>361</span>  * convert UTFa hexadecimal string to a URLComponent string such like "%67%68".&lt;br/>
<span class='line'>362</span>  * Note that these "&lt;code>0-9A-Za-z!'()*-._~&lt;/code>" characters will not
<span class='line'>363</span>  * converted to "%xx" format by builtin 'encodeURIComponent()' function.
<span class='line'>364</span>  * However this 'encodeURIComponentAll()' function will convert 
<span class='line'>365</span>  * all of characters into "%xx" format.
<span class='line'>366</span>  * @param {String} s hexadecimal string
<span class='line'>367</span>  * @return {String} URIComponent string such like "%67%68"
<span class='line'>368</span>  * @since 1.1
<span class='line'>369</span>  */</span><span class="WHIT">
<span class='line'>370</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">u8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">u8</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"%"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">      </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">      </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">      </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"%"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>383</span> 
<span class='line'>384</span> </span><span class="COMM">// ==== new lines ================================</span><span class="WHIT">
<span class='line'>385</span> </span><span class="COMM">/**
<span class='line'>386</span>  * convert all DOS new line("\r\n") to UNIX new line("\n") in 
<span class='line'>387</span>  * a String "s".
<span class='line'>388</span>  * @param {String} s string 
<span class='line'>389</span>  * @return {String} converted string
<span class='line'>390</span>  */</span><span class="WHIT">
<span class='line'>391</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">newline_toUnix</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\r\n/mg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>394</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>395</span> 
<span class='line'>396</span> </span><span class="COMM">/**
<span class='line'>397</span>  * convert all UNIX new line("\r\n") to DOS new line("\n") in 
<span class='line'>398</span>  * a String "s".
<span class='line'>399</span>  * @param {String} s string 
<span class='line'>400</span>  * @return {String} converted string
<span class='line'>401</span>  */</span><span class="WHIT">
<span class='line'>402</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">newline_toDos</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\r\n/mg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\n/mg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\r\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>406</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>407</span> 
<span class='line'>408</span> </span><span class="COMM">// ==== others ================================</span><span class="WHIT">
<span class='line'>409</span> 
<span class='line'>410</span> </span><span class="COMM">/**
<span class='line'>411</span>  * find index of string where two string differs
<span class='line'>412</span>  * @param {String} s1 string to compare
<span class='line'>413</span>  * @param {String} s2 string to compare
<span class='line'>414</span>  * @return {Number} string index of where character differs. Return -1 if same.
<span class='line'>415</span>  * @since jsrsasign 4.9.0 base64x 1.1.5
<span class='line'>416</span>  * @example
<span class='line'>417</span>  * strdiffidx("abcdefg", "abcd4fg") -> 4
<span class='line'>418</span>  * strdiffidx("abcdefg", "abcdefg") -> -1
<span class='line'>419</span>  * strdiffidx("abcdefg", "abcdef") -> 6
<span class='line'>420</span>  * strdiffidx("abcdefgh", "abcdef") -> 6
<span class='line'>421</span>  */</span><span class="WHIT">
<span class='line'>422</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">strdiffidx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s1.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s1.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">s2.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s2.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s1.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">s2.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s1.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">s2.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// same</span><span class="WHIT">
<span class='line'>430</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>431</span> </span></pre></body></html>